package com.utf999.qiangmanger.entity.orm;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.utf999.qiangmanger.entity.UUIDEntity;

/**
 * 系统管理员和门店管理员的用户信息记录在这里
 * @author yinwenjie
 */
@Entity
@Table(name="B_AdminUser")
public class AdminUserEntity extends UUIDEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5846074534843365203L;

	/**
	 * 管理员用户名
	 */
	@Column(name="userName" , length=128 , nullable=false , unique=true)
	private String userName;
	
	/**
	 * 加密后的用户登录密码
	 */
	@Column(name="encodePassword" , length=128 , nullable=false)
	private String encodePassword;
	
	/**
	 * 管理员级别<br>
	 * 1、超级管理员；2、公司管理员；3、店面管理员；4、收银员
	 */
	@Column(name="adminLevel" , nullable=false)
	private Integer adminLevel = 1;
	
	/**
	 * 管理员状态。不能做真删除。只能做逻辑删除<br>
	 * 1、正常
	 * 0、不正常
	 */
	@Column(name="status" , nullable=false)
	private Integer status = 1;
	
	/**
	 * 创建（加入店面）的时间
	 */
	@Column(name="joinTime" , nullable=false)
	private Date joinTime = new Date();
	
	/**
	 * 最后登录时间
	 */
	@Column(name="lastlogTime" , nullable=false)
	private Date lastlogTime = new Date();
	
	/**
	 * 所属店面
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="storefront" , nullable=true)
	private StorefrontEntity storefront;
	
	/**
	 * 所属公司（冗余信息），方便查询
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="company" , nullable=true)
	private CompanyEntity company;
	
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getEncodePassword() {
		return encodePassword;
	}

	public void setEncodePassword(String encodePassword) {
		this.encodePassword = encodePassword;
	}

	public Integer getAdminLevel() {
		return adminLevel;
	}

	public void setAdminLevel(Integer adminLevel) {
		this.adminLevel = adminLevel;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Date getJoinTime() {
		return joinTime;
	}

	public void setJoinTime(Date joinTime) {
		this.joinTime = joinTime;
	}

	public StorefrontEntity getStorefront() {
		return storefront;
	}

	public void setStorefront(StorefrontEntity storefront) {
		this.storefront = storefront;
	}

	public CompanyEntity getCompany() {
		return company;
	}

	public void setCompany(CompanyEntity company) {
		this.company = company;
	}

	public Date getLastlogTime() {
		return lastlogTime;
	}

	public void setLastlogTime(Date lastlogTime) {
		this.lastlogTime = lastlogTime;
	}

	/* (non-Javadoc)
	 * @see com.utf999.qiangmanger.entity.UUIDEntity#getUniqueKey()
	 */
	@Override
	public String getUniqueKey() {
		return "uid";
	}
}
